#include <stdio.h>

int do_bs(int* nums, int numsSize, int l, int r, int target)
{
    if (r < l)
        return -1;
    int mid = l + (r-l) /2;
    if (nums[mid] == target)
        return mid;
    else if (nums[mid] < target)
        return do_bs(nums, numsSize, mid+1, r, target);
    else
        return do_bs(nums, numsSize, l, mid-1, target);
}

int search(int* nums, int numsSize, int target) {
    return do_bs(nums, numsSize, 0, numsSize-1, target);
}

int main(void) {
    printf("#704. 二分查找\n");
    int nums[] = {4,6,0};
    int idx = search(nums, sizeof(nums)/sizeof(int), 9);

    printf("ret %d\n", idx);
}